package com.example.pilipili.dao;

import com.example.pilipili.pojo.dto.CommentDto;
import com.example.pilipili.pojo.entity.Comment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author liyv
 * @since 2023-12-01
 */
@Mapper
public interface CommentMapper extends BaseMapper<Comment> {
    @Select("select c.time,c.id,c.parent_id , c.content , c.uid , u.name as uname,u.hand_url  from comment c" +
            "         join user u on u.id = c.uid" +
            "         where c.vid=#{vid} and c.parent_id is null  " +
            "order by time desc")
    List<CommentDto> getsParent(@Param("vid") int vid) ;

    @Select("select c.time,c.id,c.parent_id , c.content , c.uid , u.name as uname,u.hand_url  from comment c" +
            "         join user u on u.id = c.uid" +
            "         where c.vid=#{vid} and c.parent_id = #{pid} order by time desc")
    List<CommentDto> selectListByVP(@Param("vid") int vid,@Param("pid") int pid) ;

}
